package zy.blogs.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.Optional;

/*车辆实体*/
@TableName("vehicle")
@Data
public class Vehicle {
    @TableId(type = IdType.AUTO)
    private Long id;
    @TableField("licence_plate")
    private String licencePlate;//车牌号
    private String picUrl;//车辆入场照片储存位置
    private boolean isActive;//入场.离场标记,true:入场,否则是离场
    private ParkingLot parkingLot;//关联的停车场
    public Vehicle(){
        this.isActive=true;
    }

    public Vehicle(Vehicle entity) {
        this.id =entity.id ;
        this.licencePlate = entity.licencePlate;

        this.isActive = entity.isActive;
        this.picUrl = entity.picUrl;
        Optional.ofNullable(entity.parkingLot)
                .ifPresent(x->{
                    this.parkingLot=new ParkingLot();
                    this.parkingLot.setId(x.getId());
                    this.parkingLot.setName(x.getName());
                    this.parkingLot.setVolumetric(x.getVolumetric());
                        });

    }


}
